package com.cares.sh.service.impl;

import com.cares.sh.mapper.UserMapper;
import com.cares.sh.model.User;
import com.cares.sh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;

    @Override
    public Long insert(User user) {
        user.setCreateGmt(LocalDateTime.now());
        user.setUpdateGmt(LocalDateTime.now());
        userMapper.insert(user);
        return user.getId();
    }

    @Override
    public User selectById(Long id) {
        return userMapper.selectById(id);
    }

    @Override
    public List<User> list() {
        return userMapper.selectAll();
    }

    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }
}
